<template>
  <div >
    <a-form-model class="fromModels" ref="alipayPaymentSettingModel"  :model="alipayPaymentSettingFroms" layout="vertical" 
    :labelCol="{span: 6}" :wrapperCol="{span: 12}">
        <a-form-model-item label="APPID" :rules ="[
          {required: true, message: '请输入APPID', trigger: 'blur'}
        ]">
          <a-input v-model="alipayPaymentSettingFroms.app_id"  placeholder="请输入APPID" />
        </a-form-model-item>
        <a-form-model-item label="应用私钥" :rules ="[
          {required: true, message: '请输入应用私钥', trigger: 'blur'}
        ]">
          <a-input v-model="alipayPaymentSettingFroms.app_secret_cert"  placeholder="请输入应用私钥" />
        </a-form-model-item>
        <a-form-model-item label="APP公钥证书" :rules ="[
          {required: true, message: '请输入APP公钥证书', trigger: 'blur'}
        ]">
        <upImage :urls.sync="alipayPaymentSettingFroms.app_public_cert_path"></upImage>
          <!-- <a-input v-model="alipayPaymentSettingFroms.app_public_cert_path"  placeholder="请输入APP公钥证书" /> -->
        </a-form-model-item>
        <a-form-model-item label="支付宝公钥证书" :rules ="[
          {required: true, message: '请输入支付宝公钥证书', trigger: 'blur'}
        ]">
        <upImage :urls.sync="alipayPaymentSettingFroms.alipay_public_cert_path"></upImage>
          <!-- <a-input v-model="alipayPaymentSettingFroms.alipay_public_cert_path"  placeholder="请输入支付宝公钥证书" /> -->
        </a-form-model-item>
        <a-form-model-item label="支付宝根证书" :rules ="[
          {required: true, message: '请输入支付宝根证书', trigger: 'blur'}
        ]">
        <upImage :urls.sync="alipayPaymentSettingFroms.alipay_root_cert_path"></upImage>
          <!-- <a-input v-model="alipayPaymentSettingFroms.alipay_root_cert_path"  placeholder="请输入支付宝根证书" /> -->
        </a-form-model-item>
        <a-form-model-item label="AES密钥" :rules ="[
          {required: true, message: '请输入AES密钥', trigger: 'blur'}
        ]">
          <a-input v-model="alipayPaymentSettingFroms.encrypt_key"  placeholder="请输入AES密钥" />
        </a-form-model-item>
        <a-form-model-item label="异步回调地址" :rules ="[
          {required: true, message: '请输入异步回调地址', trigger: 'blur'}
        ]">
          <a-input v-model="alipayPaymentSettingFroms.notify_url"  placeholder="请输入异步回调地址" />
        </a-form-model-item>
        <a-form-model-item label="礼包购买回调地址" :rules ="[
          {required: true, message: '请输入礼包购买回调地址', trigger: 'blur'}
        ]">
          <a-input v-model="alipayPaymentSettingFroms.gift_notify_url"  placeholder="请输入礼包购买回调地址" />
        </a-form-model-item>
        <a-form-model-item  :wrapper-col="{ span: 12, offset:5 }">
          <a-button type="primary" @click="whites">提交</a-button>
        </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import {getAlipayConfigApi,updateAlipayConfigApi } from '@/api/system.js'
import upImage from '@/components/upImage'
export default {
  name: 'alipayPaymentSetting',
  components: {
    upImage
  },
  data() {
      return {
        alipayPaymentSettingFroms:{
          app_id:"",
          alipay_public_cert_path:"",
          alipay_root_cert_path:"",
          app_public_cert_path:"",
          app_secret_cert:"",
          encrypt_key:"",
          gift_notify_url:"",
          notify_url:"",
        },
      }
  },
  created(){
    this.getPrivacyAgreementInfo()
  },
  methods:{
    getPrivacyAgreementInfo(){
      getAlipayConfigApi({
        brand_id: process.env.VUE_APP_BRAND_ID,
      }).then(res=>{
        this.alipayPaymentSettingFroms=res.data
      })
    },
    whites(){
      updateAlipayConfigApi({
        brand_id: process.env.VUE_APP_BRAND_ID,
        ...this.alipayPaymentSettingFroms
      }).then(res=>{
        this.$message.success("操作成功");
      })
    },
  }
}
</script>

<style lang="less" scoped>
</style>
